//
//  MBBaseViewController.swift
//  MicroBlog
//
//  Created by ChenJunWen on 2017/11/28.
//  Copyright © 2017年 CJW. All rights reserved.
//

import UIKit

class MBBaseViewController: UIViewController {

    lazy var customNavBar = UINavigationBar(frame: CGRect(x: 0, y: 0, width: UIScreen.jw_screenWidth(), height: 64))
    lazy var customNavItem = UINavigationItem()
    
    override func viewDidLoad() {
        super.viewDidLoad()

        
        setupUI()
    }

    override var title: String? {
        didSet {
            customNavItem.title = title
        }
    }
    
    @objc func backAction() -> () {
        let vc = MBTestViewController()
        
        navigationController?.pushViewController(vc, animated: true)
    }

}

// MARK: - 设置
extension MBBaseViewController {
    func setupUI() -> () {
        view.backgroundColor = UIColor.jw_random()
        
        setupNavigationBar()
    }
    
    private func setupNavigationBar() {
        view.addSubview(customNavBar)
        customNavBar.items = [customNavItem]
        
        customNavBar.barTintColor = UIColor.jw_color(withHex: 0xf6f6f6)
        customNavBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.darkGray]
        customNavBar.tintColor = UIColor.orange
    }
    
}
